#pragma once

#include "precompiled.h"
#include "Common.h"
#include "RenderDefines.h"
#include "HealthComponent.h"
#include "DeathComponent.h"

class Model;
class Camera_Alt;

class Scenery
{
public:
	Scenery( );
	Scenery( std::string model_key, bool IsStatic );
	~Scenery(void);

	void Set_Position( glm::vec4 pos );

	glm::vec3 Get_Extents( );
	std::string GetName();


	void SetWorldMatrix( glm::mat4 &world );

	void Initial_Position( glm::vec4 pos );
	void Initial_Translate( glm::vec3 translation );
	void Initial_Scale( glm::vec3 scale );
	void Initial_Rotate( glm::vec3 rotate );

	void Update( GLdouble time );

	void Draw( glm::mat4 &projview, Camera_Alt const * cam );

	float healthAmount();
	bool isDead();
	void lowerHealth( int amount );

	void doDeath(  );
	bool didDeath();

	// Get.
	const bool &GetIsStatic() const;
	const glm::vec4 &Scenery::GetPosition() const;
	const glm::vec3 &Scenery::GetRotation() const;
	const glm::vec3 &GetScale() const;

	// Set.
	void setDoDraw( bool val );
	void setDoFlash( );
	void setFlashable( bool val );

private:
	void create_name();
	void form_model_transform();

	bool isStatic;

	std::string name;
	Model *ref_model;				// Reference to a model in the pool. Don't destroy lol.
	TransformationCore initial_transform, transform;
	
	glm::mat4 world;

	bool doDraw, doDraw_life;
	RenderTicket rticket;

	float flash;
	bool flashable;

	HealthComponent health;
	DeathComponent death;
};

inline const bool &Scenery::GetIsStatic() const{ 
	return isStatic; }

inline const glm::vec4 &Scenery::GetPosition() const{
	return initial_transform._position;
}
inline const glm::vec3 &Scenery::GetRotation() const{
	return initial_transform._rotation;
}
inline const glm::vec3 &Scenery::GetScale() const{
	return initial_transform._scale;
}
inline void Scenery::setDoDraw( bool val ){
	doDraw=val;
}
inline void Scenery::setFlashable( bool val ){
	flashable=val;
}